#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
const int maxn = 1005;
class tele{
	int n, m, k;
	int **f;
	vector<pair<int,int> >list[maxn];
	void dfs(int p,int step);
public:	
	int init();
	int dp();

};
int tele::init()
{
	if(EOF == scanf("%d%d%d",&n,&m,&k))
		return 0;
	for(int i = 1; i <= n; i++){
		list[i].clear();
	}
	int x, y, l;
	for(int i = 0; i < m; i++){
		scanf("%d%d%d",&x,&y,&l);
		list[x].push_back(make_pair(y,l));
		list[y].push_back(make_pair(x,l));
	}
	return 1;
}
void tele::dfs(int p, int step)
{
	for(int i = 0; i < list[p].size(); i++){
		int y = list[p][i].first;
		int l = list[p][i].second;
		int min = f[step][p]>l?f[step][p]:l;
		if(f[step][y] < 0 || f[step][y] > min){
			f[step][y] = min;
			dfs(y,step);
		}
		if(step+1<=k && (f[step+1][y] < 0 || f[step+1][y] > f[step][p]))
		{
			f[step+1][y] = f[step][p];
			dfs(y,step+1);
		}
	}
}
int tele::dp()
{	
	f = new int* [k+1];
	for(int i = 0; i < k+1; i++)
		f[i] = new int [n+1];
	for(int i = 0; i <= k; i++)
		for(int j = 1; j <= n; j++)
			f[i][j] = -1;
	for(int i = 0; i <= k; i++)
		f[i][1] = 0;
	/*for(int i = 0; i < list[1].size(); i++){
		f[0][list[1][i].first] = list[1][i].second;
		f[1][list[1][i].first] = 0;
	}*/
	dfs(1,0);
    int ans = -1;
	for(int i = 0; i <= k; i++){
		if(f[i][n] >= 0 && ( ans < 0 || ans > f[i][n]))
			ans = f[i][n];
		delete[] f[i];
	}
	delete f;
	printf("%d\n",ans);
	return ans;
}
int main()
{
	tele test;
	while(test.init()){
		test.dp();
	}
	return 0;
}
